# Copyright (c) 2008-2009 Mikhail Chernov 
#
# This file is part of dcExplorer.
#
# dcExplorer is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# dcExplorer is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with dcExplorer.  If not, see <http://www.gnu.org/licenses/>.

package dcExplorer::layer::Selection;

sub new
{
	my $proto = shift;
	my $class = ref($proto) || $proto;
	my $self = {};
	$self->{Selection} = undef;
	bless ($self, $class);
	return $self;
}

sub setSelection
{
	my $self = shift;
	$self->{Selection} = shift;
}

sub display
{
	my $self = shift;
	my $canvas = shift;
	return unless $self->{Selection};
	my ($x, $y) = @{$self->{Selection}};
	$x += 2000 if ($x < $canvas->{'min_x'});
	$y += 2000 if ($y < $canvas->{'min_y'});
	return if ($x > $canvas->{max_x} || $y > $canvas->{max_y}); 

	my $fg = dcExplorer::canvas::Color->new(255, 0, 255);
	my $penSize = 3;

	my @rect = $canvas->rect($x, $y);
	$rect[2]++;
	$rect[3]++;
	$canvas->Rectangle(@rect, $fg, $penSize + 1);
}

1;
